<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.19"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Modbus cpp: MB::ModbusException Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Modbus cpp
   &#160;<span id="projectnumber">0.1</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.19 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespaceMB.html">MB</a></li><li class="navelem"><a class="el" href="classMB_1_1ModbusException.html">ModbusException</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-static-methods">Static Public Member Functions</a> &#124;
<a href="classMB_1_1ModbusException-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">MB::ModbusException Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p><code>#include &lt;<a class="el" href="modbusException_8hpp_source.html">modbusException.hpp</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for MB::ModbusException:</div>
<div class="dyncontent">
 <div class="center">
  <img src="classMB_1_1ModbusException.png" alt=""/>
 </div></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a27fc098093dfa4b7ff49acebb5c4a0bf"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMB_1_1ModbusException.html#a27fc098093dfa4b7ff49acebb5c4a0bf">ModbusException</a> (const std::vector&lt; uint8_t &gt; &amp;inputData, bool CRC=false) noexcept</td></tr>
<tr class="memdesc:a27fc098093dfa4b7ff49acebb5c4a0bf"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructs Exception from raw data.  <a href="classMB_1_1ModbusException.html#a27fc098093dfa4b7ff49acebb5c4a0bf">More...</a><br /></td></tr>
<tr class="separator:a27fc098093dfa4b7ff49acebb5c4a0bf"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2c60c1d081060a266a3f868698a289b6"><td class="memItemLeft" align="right" valign="top"><a id="a2c60c1d081060a266a3f868698a289b6"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMB_1_1ModbusException.html#a2c60c1d081060a266a3f868698a289b6">ModbusException</a> (<a class="el" href="namespaceMB_1_1utils.html#aa34c557c9bf4c6bfeb86aa16b398de55">utils::MBErrorCode</a> errorCode, uint8_t slaveId=0xFF, <a class="el" href="namespaceMB_1_1utils.html#aa8ebb89b73bf4d0e3485b6341a50f116">utils::MBFunctionCode</a> functionCode=utils::Undefined) noexcept</td></tr>
<tr class="memdesc:a2c60c1d081060a266a3f868698a289b6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructs Exception based on error code, function code and slaveId. <br /></td></tr>
<tr class="separator:a2c60c1d081060a266a3f868698a289b6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a289c4eed8b2953b1ecc6e5956d00a245"><td class="memItemLeft" align="right" valign="top"><a id="a289c4eed8b2953b1ecc6e5956d00a245"></a>
uint8_t&#160;</td><td class="memItemRight" valign="bottom"><b>slaveID</b> () const noexcept</td></tr>
<tr class="separator:a289c4eed8b2953b1ecc6e5956d00a245"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2d93520088d9adac402b4558a7441d80"><td class="memItemLeft" align="right" valign="top"><a id="a2d93520088d9adac402b4558a7441d80"></a>
bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMB_1_1ModbusException.html#a2d93520088d9adac402b4558a7441d80">isSlaveValid</a> () const noexcept</td></tr>
<tr class="memdesc:a2d93520088d9adac402b4558a7441d80"><td class="mdescLeft">&#160;</td><td class="mdescRight">Checks if SlaveID is specified. <br /></td></tr>
<tr class="separator:a2d93520088d9adac402b4558a7441d80"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a344445f1b157f5e5d66946cd893c72fd"><td class="memItemLeft" align="right" valign="top"><a id="a344445f1b157f5e5d66946cd893c72fd"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMB_1_1ModbusException.html#a344445f1b157f5e5d66946cd893c72fd">setSlaveID</a> (uint8_t slaveId) noexcept</td></tr>
<tr class="memdesc:a344445f1b157f5e5d66946cd893c72fd"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets SlaveID. <br /></td></tr>
<tr class="separator:a344445f1b157f5e5d66946cd893c72fd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a99b4583ae15c2a13530e3751e9ad2737"><td class="memItemLeft" align="right" valign="top"><a id="a99b4583ae15c2a13530e3751e9ad2737"></a>
<a class="el" href="namespaceMB_1_1utils.html#aa34c557c9bf4c6bfeb86aa16b398de55">utils::MBErrorCode</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMB_1_1ModbusException.html#a99b4583ae15c2a13530e3751e9ad2737">getErrorCode</a> () const noexcept</td></tr>
<tr class="memdesc:a99b4583ae15c2a13530e3751e9ad2737"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns detected error code. <br /></td></tr>
<tr class="separator:a99b4583ae15c2a13530e3751e9ad2737"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:acddacc2b4de0b5e85275b8d1bfa67c4f"><td class="memItemLeft" align="right" valign="top">const char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMB_1_1ModbusException.html#acddacc2b4de0b5e85275b8d1bfa67c4f">what</a> () const noexcept override</td></tr>
<tr class="separator:acddacc2b4de0b5e85275b8d1bfa67c4f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a29d776e7ae321fbeba28a25df5159c79"><td class="memItemLeft" align="right" valign="top"><a id="a29d776e7ae321fbeba28a25df5159c79"></a>
std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMB_1_1ModbusException.html#a29d776e7ae321fbeba28a25df5159c79">toString</a> () const noexcept</td></tr>
<tr class="memdesc:a29d776e7ae321fbeba28a25df5159c79"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns string representation of object. <br /></td></tr>
<tr class="separator:a29d776e7ae321fbeba28a25df5159c79"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3f288bfe0b2b0f646ab0019faae78142"><td class="memItemLeft" align="right" valign="top"><a id="a3f288bfe0b2b0f646ab0019faae78142"></a>
std::vector&lt; uint8_t &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMB_1_1ModbusException.html#a3f288bfe0b2b0f646ab0019faae78142">toRaw</a> () const noexcept</td></tr>
<tr class="memdesc:a3f288bfe0b2b0f646ab0019faae78142"><td class="mdescLeft">&#160;</td><td class="mdescRight">Converts object to modbus byte representation. <br /></td></tr>
<tr class="separator:a3f288bfe0b2b0f646ab0019faae78142"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a50877c6c7466f74a984648f9bc00c37d"><td class="memItemLeft" align="right" valign="top"><a id="a50877c6c7466f74a984648f9bc00c37d"></a>
<a class="el" href="namespaceMB_1_1utils.html#aa8ebb89b73bf4d0e3485b6341a50f116">utils::MBFunctionCode</a>&#160;</td><td class="memItemRight" valign="bottom"><b>functionCode</b> () const noexcept</td></tr>
<tr class="separator:a50877c6c7466f74a984648f9bc00c37d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a037dd1f8c9927522e668897c798e3c6e"><td class="memItemLeft" align="right" valign="top"><a id="a037dd1f8c9927522e668897c798e3c6e"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>setFunctionCode</b> (<a class="el" href="namespaceMB_1_1utils.html#aa8ebb89b73bf4d0e3485b6341a50f116">utils::MBFunctionCode</a> functionCode) noexcept</td></tr>
<tr class="separator:a037dd1f8c9927522e668897c798e3c6e"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-static-methods"></a>
Static Public Member Functions</h2></td></tr>
<tr class="memitem:ae16c1019e58cbb099122f060f8a43fbf"><td class="memItemLeft" align="right" valign="top"><a id="ae16c1019e58cbb099122f060f8a43fbf"></a>
static bool&#160;</td><td class="memItemRight" valign="bottom"><b>exist</b> (const std::vector&lt; uint8_t &gt; &amp;inputData) noexcept</td></tr>
<tr class="separator:ae16c1019e58cbb099122f060f8a43fbf"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Thic class represent Modbus exception and is derived form std::exception. It is just a wrapper around standard error codes and some custom codes. </p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a27fc098093dfa4b7ff49acebb5c4a0bf"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a27fc098093dfa4b7ff49acebb5c4a0bf">&#9670;&nbsp;</a></span>ModbusException()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">ModbusException::ModbusException </td>
          <td>(</td>
          <td class="paramtype">const std::vector&lt; uint8_t &gt; &amp;&#160;</td>
          <td class="paramname"><em>inputData</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>CRC</em> = <code>false</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">explicit</span><span class="mlabel">noexcept</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Constructs Exception from raw data. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">inputData</td><td>is vector of bytes that will be be interpreted </td></tr>
    <tr><td class="paramname">CRC</td><td>based on this param method performs CRC calculation and throws exception if it is invalid </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>if CRC = true input data needs to contain 2 CRC bytes on back (used in RS) </dd></dl>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="acddacc2b4de0b5e85275b8d1bfa67c4f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#acddacc2b4de0b5e85275b8d1bfa67c4f">&#9670;&nbsp;</a></span>what()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">const char* MB::ModbusException::what </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">override</span><span class="mlabel">noexcept</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>This function is less optimal, it is just to be compatible with std::excepetion You should preferably use <a class="el" href="classMB_1_1ModbusException.html#a29d776e7ae321fbeba28a25df5159c79" title="Returns string representation of object.">toString()</a> </p>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>include/MB/<a class="el" href="modbusException_8hpp_source.html">modbusException.hpp</a></li>
<li>src/modbusException.cpp</li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="http://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.8.19
</small></address>
</body>
</html>
